<template>
  <div>
    <el-carousel :interval="4000" type="card" height="200px" style="margin-top: 20px">
      <el-carousel-item v-for="item in imgList" :key="item.id">
        <el-image :src="item.url"></el-image>
      </el-carousel-item>
    </el-carousel>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>推荐文章</span>
        <el-button style="float: right; padding: 3px 0" type="text">更多></el-button>
      </div>
      <div v-for="item in articles" :key="item" class="text item">
        <div class="article">
          <div><span style="color: #99a9bf">推荐课程</span></div>
          <div style="cursor: pointer" @click="lookArticle(item.id)">
            <div style="font-size: 20px;font-weight: 600">{{item.title}}</div>
            <div><div class="content" v-html="item.content"></div></div>
          </div>
          <div style="display: flex;color: #8c939d">
            <div style="margin-top: 2px;margin-right: 5px">{{item.create_date}}</div>
            <div>阅读{{item.readings}}万</div>
          </div>
        </div>
      </div>
    </el-card>
  </div>
</template>
<script>
export default {
  name: "author",
  data(){
    return{
      imgList:[
        {
          id:'1',
          url:'https://ccstatic-1252317822.file.myqcloud.com/operatework/app/2024-03-08/65ea7e34efab3.png'
        },{
          id:'2',
          url:'https://ccstatic-1252317822.file.myqcloud.com/operatework/app/2024-01-09/659d09e48e799.jpg'
        },{
          id:'3',
          url:'https://ccstatic-1252317822.file.myqcloud.com/operatework/app/2024-01-09/659cf86baeb9e.jpg'
        },
      ],
      articles: [],
      currentPage: 1,
      pageSize: 18
    }
  },
  mounted: function () {
    this.loadArticle()
  },
  methods: {
    loadArticle(){
      this.$axios.get('/getArticles',).then(resp => {
        if (resp) {
          this.articles = resp.data
        }
      })
    },
    lookArticle(id){
      this.$router.push({path: `/authorIndex/article/${id}`});
    }
  }
}
</script>
<style>
.content{
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:2;
    overflow:hidden;
    text-overflow:ellipsis;
}
.article{
  border-top: 1px solid #8c939d;
  margin-bottom: 20px;
}
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #d3dce6;
}
.cover {
  width: 250px;
  height: 270px;
  margin-bottom: 7px;
  overflow: hidden;
  cursor: pointer;
}

img {
  width: 115px;
  height: 250px;
}

.title {
  font-size: 14px;
  text-align: left;
}

.author {
  color: #333;
  width: 102px;
  font-size: 13px;
  margin-bottom: 6px;
  text-align: left;
}

.abstract {
  display:-webkit-box;
  line-height: 17px;
  width: 300px;
  -webkit-box-orient:vertical;
  -webkit-line-clamp:3;
  overflow:hidden;
}

a {
  text-decoration: none;
}

a:link, a:visited, a:focus {
  color: #3377aa;
}

.el-icon-circle-plus-outline {
  margin: 50px 0 0 20px;
  font-size: 100px;
  float: left;
  cursor: pointer;
}
</style>